The sample adaptive offset (SAO) technology is a coding technology newly added to the high efficiency video coding (HEVC) standard. A SAO compensator is placed behind a deblocking filter, and the SAO compensator determines a corresponding compensation parameter by classifying and counting pixels of a reconstructed image on which deblocking filtering is performed, and then performs pixel compensation on the image, thereby reducing distortion, improving a compression rate, and reducing bitstreams. The compensation parameter includes a sub-band offset compensation value, an edge offset compensation value, and the like. The compensation parameter indicates a SAO compensation method that needs to be used by a largest coding unit, including sub-band offset compensation, edge offset compensation, needing no compensation, and the like.
In the prior art, for an application at a largest coding unit (LCU) level in the HEVC standard, when the SAO compensator determines that edge offset compensation needs to be performed on a current LCU, pixel compensation needs to be performed on the entire current LCU by using pixels of LCUs that surround and are adjacent to the current LCU (including LCUs above, below, on the left of, on the right of, on the upper right of, on the lower right of, on the upper left of, and on the lower left of the current LCU). Therefore, pixel compensation cannot be performed on the current LCU until the LCU on the lower right of a currently received LCU is received.
Therefore, compared with the deblocking filter placed before the SAO compensator, the SAO compensator has a latency of more than one LCU row, and this latency is great, which cannot meet a highly time sensitive scenario. In addition, because compared with the deblocking filter, the SAO compensator has a latency of more than one LCU row, the SAO compensator further needs to buffer a received LCU on which pixel compensation is not performed. If an LCU has a size of N*N pixels, and a width of an image is X pixels, where X≥N and both X and N are positive integers, N*X+2*N*N pixels need to be buffered. Therefore, an amount of data that needs to be buffered is large, and occupied resources are substantial, causing an increase of costs.